Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Rails integration in dotenv gem and refactor #468

Merged
merged 8 commits into from
Jan 20, 2024
Merged

Conversation

bkeepers
Copy link
Owner

This refactors the Rails integration, and includes it in the dotenv gem by default.

  • Renames Dotenv::Railtie => Dotenv::Rails
  • Adds Dotenv::Rails.files, which can be mutated to change which files are loaded
  • Adds Dotenv::Rails.overwrite = true to overwrite existing ENV variables

I thought about deprecating the dotenv-rails gem, but for now I can just keep releasing it as an empty gem with a dependency on dotenv.

Base automatically changed from refactor to master January 20, 2024 20:08
@bkeepers bkeepers merged commit d159398 into master Jan 20, 2024
4 checks passed
@bkeepers bkeepers deleted the refactor-rails branch January 20, 2024 20:08
indiebrain referenced this pull request in powerhome/power-web-development-interview Feb 13, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [dotenv-rails](https://github.com/bkeepers/dotenv) | `2.8.1` ->
`3.0.0` |
[![age](https://developer.mend.io/api/mc/badges/age/rubygems/dotenv-rails/3.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/rubygems/dotenv-rails/3.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/rubygems/dotenv-rails/2.8.1/3.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/rubygems/dotenv-rails/2.8.1/3.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>bkeepers/dotenv (dotenv-rails)</summary>

###
[`v3.0.0`](https://github.com/bkeepers/dotenv/blob/HEAD/Changelog.md#300)

[Compare
Source](https://github.com/bkeepers/dotenv/compare/v2.8.1...v3.0.0)

**Breaking Changes**

- Ruby >= 3.0 and Rails >= 6.1 are now required. Lock dotenv to `~> 2.0`
if you are using an outdated Ruby or Rails version.
[https://github.com/bkeepers/dotenv/pull/466](https://github.com/bkeepers/dotenv/pull/466),
[https://github.com/bkeepers/dotenv/pull/471](https://github.com/bkeepers/dotenv/pull/471)
- `\n` is no longer expanded into a newline in quoted strings. Use
multi-line strings with real line breaks, or set
`DOTENV_LINEBREAK_MODE=legacy` to preserve the old behavior.
[@&#8203;nitsujri](https://github.com/nitsujri)
[https://github.com/bkeepers/dotenv/pull/423](https://github.com/bkeepers/dotenv/pull/423)
- `ENV` will be [automatically restored between
tests](https://github.com/bkeepers/dotenv#autorestore-in-tests)
(`ActiveSupport::TestCase` and `Rspec`).
[https://github.com/bkeepers/dotenv/pull/472](https://github.com/bkeepers/dotenv/pull/472),
[https://github.com/bkeepers/dotenv/pull/475](https://github.com/bkeepers/dotenv/pull/475)
- Fixed precedence when using `Dotenv::Rails.overload`. So now
`.env.development.local` will overwrite `.env.local`, which will
overwrite `.env.development`, which will overwrite `.env`.
[@&#8203;eriklovmo](https://github.com/eriklovmo) -
[https://github.com/bkeepers/dotenv/pull/460](https://github.com/bkeepers/dotenv/pull/460)
- The instrumentation event `dotenv.load` has been renamed to
`load.dotenv` to properly make use of namespaces in
[ActiveSupport::Notifications](https://guides.rubyonrails.org/active_support_instrumentation.html)
[https://github.com/bkeepers/dotenv/pull/472](https://github.com/bkeepers/dotenv/pull/472)

**Other improvements**

- All changes to ENV will be logged in Rails apps.
[https://github.com/bkeepers/dotenv/pull/473](https://github.com/bkeepers/dotenv/pull/473)
- Fixed an issue where `rake` loaded development files
(`.env*development`) for test-related tasks.
[https://github.com/bkeepers/dotenv/pull/470](https://github.com/bkeepers/dotenv/pull/470)
- Add `-i`/`--ignore` option to `dotenv` CLI to optionally ignore
missing files. [@&#8203;stevenharman](https://github.com/stevenharman)
[https://github.com/bkeepers/dotenv/pull/463](https://github.com/bkeepers/dotenv/pull/463)
- You can [customize which files get
loaded](https://github.com/bkeepers/dotenv#customizing-rails) by
setting `Dotenv::Rails.files`.
[https://github.com/bkeepers/dotenv/pull/468](https://github.com/bkeepers/dotenv/pull/468)

**Deprecations**

- The `dotenv-rails` gem is now superfluous. It's not technically
deprecated yet and will continue to work, but the `dotenv` gem does the
same thing.
[https://github.com/bkeepers/dotenv/pull/468](https://github.com/bkeepers/dotenv/pull/468)
- `Dotenv::Railtie` has been deprecated. Use `Dotenv::Rails`.
[https://github.com/bkeepers/dotenv/pull/468](https://github.com/bkeepers/dotenv/pull/468)
- `Dotenv.overload` has been replaced with `overwrite`. `overload` will
still work and is not technically deprecated, but documentation refers
to `Dotenv.overwrite` now.
[https://github.com/bkeepers/dotenv/pull/469](https://github.com/bkeepers/dotenv/pull/469)

**New Contributors**

- [@&#8203;stevenharman](https://github.com/stevenharman) made their
first contribution in
[https://github.com/bkeepers/dotenv/pull/463](https://github.com/bkeepers/dotenv/pull/463)
- [@&#8203;eriklovmo](https://github.com/eriklovmo) made their first
contribution in
[https://github.com/bkeepers/dotenv/pull/460](https://github.com/bkeepers/dotenv/pull/460)
- [@&#8203;nitsujri](https://github.com/nitsujri) made their first
contribution in
[https://github.com/bkeepers/dotenv/pull/423](https://github.com/bkeepers/dotenv/pull/423)

**Full Changelog**:
bkeepers/dotenv@v2.8.1...v3.0.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/powerhome/power-web-development-interview).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xNzMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjE3My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
rioug added a commit to openfoodfoundation/openfoodnetwork that referenced this pull request Feb 13, 2024
From dotenv V3 changelog:
> The dotenv-rails gem is now superfluous. It's not technically
  deprecated yet and will continue to work, but the dotenv gem does the
  same thing. bkeepers/dotenv#468
floehopper added a commit to freerange/site that referenced this pull request Feb 29, 2024
The former now incorporates the latter and the latter will soon be
deprecated. See this PR [1] for details.

[1]: bkeepers/dotenv#468
phinze pushed a commit to chicago-tool-library/circulate that referenced this pull request Mar 11, 2024
# What it does

Updates us to dotenv 3, and moves to using that gem directly instead of
`dotenv-rails` which is [no longer
necessary](bkeepers/dotenv#468).

This effectively the same as #1378, but moves to using `dotenv` as a
direct dependency.
fleblond07 pushed a commit to fleblond07/openfoodnetwork that referenced this pull request Mar 13, 2024
From dotenv V3 changelog:
> The dotenv-rails gem is now superfluous. It's not technically
  deprecated yet and will continue to work, but the dotenv gem does the
  same thing. bkeepers/dotenv#468
rossta added a commit to joyofrails/joyofrails.com that referenced this pull request Mar 17, 2024
The -rails gem is no longer needed
bkeepers/dotenv#468
rossta added a commit to joyofrails/joyofrails.com that referenced this pull request Mar 17, 2024
The -rails gem is no longer needed
bkeepers/dotenv#468
olliebennett added a commit to olliebennett/homepicker that referenced this pull request Apr 15, 2024
parndt pushed a commit to rubynz/membership-register that referenced this pull request Jun 30, 2024
Main things:

* Update rails
* Replace dotenv-rails with dotenv (See bkeepers/dotenv#468 )
* Update all of the other gems
* Fix some controllers tests and add a missing one

Honestly, I am not too happy with the way I fixed the controllers tests. Rails probably changed and it needs now the ENV var at boot. Happy to have someone else trying.

:v:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant